#include "../../common/detail.hpp"
#include "../../server/rpc_server.hpp"



void Add(const Json::Value &req,Json::Value &rsp)
{
    int num1=req["num1"].asInt();
    int num2=req["num2"].asInt();
    rsp=num1+num2;
    DLOG("调用[Add]服务-result：%d",rsp.asInt());
}

int main()
{


    std::unique_ptr<Json_rpc::server::SDescribeFacyory> desc_factory(new Json_rpc::server::SDescribeFacyory);
    // auto desc_factory(new Json_rpc::server::SDescribeFacyory);

    desc_factory->setMethodName("Add");
    desc_factory->setParamsDesc("num1",Json_rpc::server::VType::INTEGRAL);
    desc_factory->setParamsDesc("num2",Json_rpc::server::VType::INTEGRAL);
    desc_factory->setReturnType(Json_rpc::server::VType::INTEGRAL);
    desc_factory->setCallback(Add);

    Json_rpc::server::RpcServer server(Json_rpc::Address("127.0.0.1",9090),true,Json_rpc::Address("127.0.0.1",8888));

    server.registerMethod(desc_factory->build());

    server.start();
    return 0;
}